source("03_create_soe_share.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/code/")
source("04_create_final_dataset.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/code/")
source("05_create_total_isic.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/code/")
source("06_figure_1.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/code/")
source("07_figure_2.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/code/")
source("08_figure_3.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/code/")
source("09_table_1.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/code/")
source("10_figure_4.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/code/")
source("11_figure_5.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("B1_create_table_1.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("B2_create_alt_strategic.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("B3_create_figure_3.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("B4_create_table_2.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("B5_create_table_3.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C1_create_rnd_only.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C2_create_figure_4.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C3_create_gp0911_only.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C4_create_figure_5.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C5_create_figure_6.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C6_create_figure_7.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C7_create_figure_8.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C8_create_or_only.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C9_create_figure_9.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C10_create_lcr_only.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C11_create_figure_10.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C12_create_gp_only.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C13_create_figure_11.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C14_create_figures_12_13.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C15_create_figure_14.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C16_create_figures_15_16.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("C17_create_figure_17.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("D1_create_table_4.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("E1_create_marketsize.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("E2_create_table_5.R", echo = TRUE)
setwd("/Users/John/Dropbox/JOP_Replication_Materials/appendix/code")
source("E3_create_table_6.R", echo = TRUE)
# Finish log
cat("\n=== Replication completed at", Sys.time(), "===\n")
sink()
# figure_4.R
rm(list = ls())
setwd("/Users/John/Dropbox/")
# --- Load Required Packages ---
library(readr)
library(interflex)
library(tidyverse)
# --- Load Data  ---
df <- read_csv("JOP_Replication_Materials/data/processed/final_dataset.csv")
# --- Prepare Data ---
intflex <- df %>%
dplyr::select(isic, year, strategic, isic_year, median_share,
med_hhi_isic2, med_soe_isic2) %>%
mutate(Strategic = strategic)
intflex <- as.data.frame(intflex)
# --- Run Interflex Model ---
int.p <- interflex(
estimator = "binning",
Y = "isic_year",
D = "Strategic",
X = "median_share",
Z = c("med_hhi_isic2", "med_soe_isic2"),
data = intflex,
vcov.type = "cluster",
cl = "isic",
na.rm = TRUE,
main = "Marginal Effect of Strategic Status on Tech Absorption",
Ylabel = "Tech Abs. Policies",
Xlabel = "Median Processing Share",
method = "poisson",
cex.main = 1,
ncols = 1,
theme.bw = TRUE,
nbins = 3,
bin.labs = FALSE
)
# --- Print figure ---
plot(int.p$figure + theme(plot.margin = margin(10, 10, 10, 10)))
int.p$tests$p.wald
# Manually save as "Dropbox/JOP_Replication_Materials/output/figures/figure_4.pdf" to ensure best figure dimensions
# -- Print Bin Estimates for Log File ---
print(int.p$est.bin)
# figure_5.R
rm(list = ls())
setwd("/Users/John/Dropbox/")
# --- Load Required Packages ---
library(readr)
library(interflex)
library(tidyverse)
# --- Load Data ---
df <- read_csv("JOP_Replication_Materials/data/processed/final_dataset.csv")
# --- Interflex Model ---
intflex <- df %>%
dplyr::select(isic, isic2, year, strategic, isic_year, median_share,
med_hhi_isic2, med_soe_isic2) %>%
mutate(Strategic = strategic)
intflex <- as.data.frame(intflex)
# --- Estimate with Poisson ---
int.p <- interflex(
estimator = "linear",
Y = "isic_year",
D = "Strategic",
X = "median_share",
Z = c("med_hhi_isic2", "med_soe_isic2"),
data = intflex,
vcov.type = "cluster",
cl = c("isic"),
na.rm = TRUE,
main = "Marginal Effect of Strategic Status on Tech Absorption \nPoisson w/ Cluster Robust SEs",
Ylabel = "Tech Absorption Policies",
Xlabel = "Median Processing Share",
method = "poisson",
cex.main = 1,
ncols = 1,
theme.bw = TRUE,
nbins = 3,
bin.labs = FALSE
)
figure <- predict(int.p,
main = "Expected No. of Tech Absorption Policies by Strategic Status\n and Median Processing Share",
theme.bw = TRUE,
subtitles = c("Not Strategic", "Strategic"),
cex.axis = 1,
cex.lab = 1.2,
cex.sub = 1.2)
plot(figure + theme(plot.margin = margin(10, 10, 10, 10)))
# Manually save as "Dropbox/JOP_Replication_Materials/output/figures/figure_5.pdf" to ensure best figure dimensions
# Set base working directory for the log file
setwd("/Users/John/Dropbox/JOP_Replication_Materials/Logs/")
sink("replication_log.txt", split = TRUE)
cat("Replication Log started at", Sys.time(), "\n\n")
# Define paths
main_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/code/"
appendix_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/appendix/code/"
# List of main scripts
main_scripts <- c(
"01_create_process_share.R",
"02_create_hhi.R",
"03_create_soe_share.R",
"04_create_final_dataset.R",
"05_create_total_isic.R",
"06_figure_1.R",
"07_figure_2.R",
"08_figure_3.R",
"09_table_1.R",
"10_figure_4.R",
"11_figure_5.R"
)
# List of appendix scripts
appendix_scripts <- c(
"B1_create_table_1.R",
"B2_create_alt_strategic.R",
"B3_create_figure_3.R",
"B4_create_table_2.R",
"B5_create_table_3.R",
"C1_create_rnd_only.R",
"C2_create_figure_4.R",
"C3_create_gp0911_only.R",
"C4_create_figure_5.R",
"C5_create_figure_6.R",
"C6_create_figure_7.R",
"C7_create_figure_8.R",
"C8_create_or_only.R",
"C9_create_figure_9.R",
"C10_create_lcr_only.R",
"C11_create_figure_10.R",
"C12_create_gp_only.R",
"C13_create_figure_11.R",
"C14_create_figures_12_13.R",
"C15_create_figure_14.R",
"C16_create_figures_15_16.R",
"C17_create_figure_17.R",
"D1_create_table_4.R",
"E1_create_marketsize.R",
"E2_create_table_5.R",
"E3_create_table_6.R"
)
# Run all scripts
for (s in main_scripts) run_script(file.path(main_code_dir, s))
# Set base working directory for the log file
setwd("/Users/John/Dropbox/JOP_Replication_Materials/Logs/")
sink("replication_log.txt", split = TRUE)
cat("Replication Log started at", Sys.time(), "\n\n")
# Helper function to run scripts from a given directory
run_script <- function(script_path) {
original_wd <- getwd()
script_dir <- dirname(script_path)
script_file <- basename(script_path)
setwd(script_dir)
cat("\n--- Running:", script_file, "from", script_dir, "at", Sys.time(), "---\n")
source(script_file, echo = TRUE)
setwd(original_wd)
}
# Define paths
main_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/code/"
appendix_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/appendix/code/"
# List of main scripts
main_scripts <- c(
"01_create_process_share.R",
"02_create_hhi.R",
"03_create_soe_share.R",
"04_create_final_dataset.R",
"05_create_total_isic.R",
"06_figure_1.R",
"07_figure_2.R",
"08_figure_3.R",
"09_table_1.R",
"10_figure_4.R",
"11_figure_5.R"
)
# List of appendix scripts
appendix_scripts <- c(
"B1_create_table_1.R",
"B2_create_alt_strategic.R",
"B3_create_figure_3.R",
"B4_create_table_2.R",
"B5_create_table_3.R",
"C1_create_rnd_only.R",
"C2_create_figure_4.R",
"C3_create_gp0911_only.R",
"C4_create_figure_5.R",
"C5_create_figure_6.R",
"C6_create_figure_7.R",
"C7_create_figure_8.R",
"C8_create_or_only.R",
"C9_create_figure_9.R",
"C10_create_lcr_only.R",
"C11_create_figure_10.R",
"C12_create_gp_only.R",
"C13_create_figure_11.R",
"C14_create_figures_12_13.R",
"C15_create_figure_14.R",
"C16_create_figures_15_16.R",
"C17_create_figure_17.R",
"D1_create_table_4.R",
"E1_create_marketsize.R",
"E2_create_table_5.R",
"E3_create_table_6.R"
)
# Run all scripts
for (s in main_scripts) run_script(file.path(main_code_dir, s))
# List of main scripts
main_scripts <- c(
#"01_create_process_share.R",
"02_create_hhi.R",
"03_create_soe_share.R",
"04_create_final_dataset.R",
"05_create_total_isic.R",
"06_figure_1.R",
"07_figure_2.R",
"08_figure_3.R",
"09_table_1.R",
"10_figure_4.R",
"11_figure_5.R"
)
# List of appendix scripts
appendix_scripts <- c(
"B1_create_table_1.R",
"B2_create_alt_strategic.R",
"B3_create_figure_3.R",
"B4_create_table_2.R",
"B5_create_table_3.R",
"C1_create_rnd_only.R",
"C2_create_figure_4.R",
"C3_create_gp0911_only.R",
"C4_create_figure_5.R",
"C5_create_figure_6.R",
"C6_create_figure_7.R",
"C7_create_figure_8.R",
"C8_create_or_only.R",
"C9_create_figure_9.R",
"C10_create_lcr_only.R",
"C11_create_figure_10.R",
"C12_create_gp_only.R",
"C13_create_figure_11.R",
"C14_create_figures_12_13.R",
"C15_create_figure_14.R",
"C16_create_figures_15_16.R",
"C17_create_figure_17.R",
"D1_create_table_4.R",
"E1_create_marketsize.R",
"E2_create_table_5.R",
"E3_create_table_6.R"
)
# Run all scripts
for (s in main_scripts) run_script(file.path(main_code_dir, s))
# Set base working directory for the log file
setwd("/Users/John/Dropbox/JOP_Replication_Materials/Logs/")
sink("replication_log.txt", split = TRUE)
cat("Replication Log started at", Sys.time(), "\n\n")
# Helper function to run scripts from a given directory
run_script <- function(script_path) {
original_wd <- getwd()
script_dir <- dirname(script_path)
script_file <- basename(script_path)
setwd(script_dir)
cat("\n--- Running:", script_file, "from", script_dir, "at", Sys.time(), "---\n")
source(script_file, echo = TRUE)
setwd(original_wd)
}
# Define paths
main_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/code/"
appendix_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/appendix/code/"
# List of main scripts
main_scripts <- c(
#"01_create_process_share.R",
"02_create_hhi.R",
"03_create_soe_share.R",
"04_create_final_dataset.R",
"05_create_total_isic.R",
"06_figure_1.R",
"07_figure_2.R",
"08_figure_3.R",
"09_table_1.R",
"10_figure_4.R",
"11_figure_5.R"
)
# List of appendix scripts
appendix_scripts <- c(
"B1_create_table_1.R",
"B2_create_alt_strategic.R",
"B3_create_figure_3.R",
"B4_create_table_2.R",
"B5_create_table_3.R",
"C1_create_rnd_only.R",
"C2_create_figure_4.R",
"C3_create_gp0911_only.R",
"C4_create_figure_5.R",
"C5_create_figure_6.R",
"C6_create_figure_7.R",
"C7_create_figure_8.R",
"C8_create_or_only.R",
"C9_create_figure_9.R",
"C10_create_lcr_only.R",
"C11_create_figure_10.R",
"C12_create_gp_only.R",
"C13_create_figure_11.R",
"C14_create_figures_12_13.R",
"C15_create_figure_14.R",
"C16_create_figures_15_16.R",
"C17_create_figure_17.R",
"D1_create_table_4.R",
"E1_create_marketsize.R",
"E2_create_table_5.R",
"E3_create_table_6.R"
)
# Run all scripts
for (s in main_scripts) run_script(file.path(main_code_dir, s))
# Set base working directory for the log file
setwd("/Users/John/Dropbox/JOP_Replication_Materials/Logs/")
# --- Define helper function FIRST ---
run_script <- function(script_path) {
original_wd <- getwd()
script_dir <- dirname(script_path)
script_file <- basename(script_path)
setwd(script_dir)
cat("\n--- Running:", script_file, "from", script_dir, "at", Sys.time(), "---\n")
tryCatch({
source(script_file, echo = TRUE)
}, error = function(e) {
cat("ERROR in", script_file, ":", conditionMessage(e), "\n")
})
setwd(original_wd)
}
# Start logging AFTER functions are defined
sink("replication_log.txt", split = TRUE)
cat("Replication Log started at", Sys.time(), "\n\n")
# Define paths
main_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/code/"
appendix_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/appendix/code/"
# List of main scripts
main_scripts <- c(
"02_create_hhi.R",
"03_create_soe_share.R",
"04_create_final_dataset.R",
"05_create_total_isic.R",
"06_figure_1.R",
"07_figure_2.R",
"08_figure_3.R",
"09_table_1.R",
"10_figure_4.R",
"11_figure_5.R"
)
# List of appendix scripts
appendix_scripts <- c(
"B1_create_table_1.R",
"B2_create_alt_strategic.R",
"B3_create_figure_3.R",
"B4_create_table_2.R",
"B5_create_table_3.R",
"C1_create_rnd_only.R",
"C2_create_figure_4.R",
"C3_create_gp0911_only.R",
"C4_create_figure_5.R",
"C5_create_figure_6.R",
"C6_create_figure_7.R",
"C7_create_figure_8.R",
"C8_create_or_only.R",
"C9_create_figure_9.R",
"C10_create_lcr_only.R",
"C11_create_figure_10.R",
"C12_create_gp_only.R",
"C13_create_figure_11.R",
"C14_create_figures_12_13.R",
"C15_create_figure_14.R",
"C16_create_figures_15_16.R",
"C17_create_figure_17.R",
"D1_create_table_4.R",
"E1_create_marketsize.R",
"E2_create_table_5.R",
"E3_create_table_6.R"
)
# Run all scripts
for (s in main_scripts) run_script(file.path(main_code_dir, s))
# Set base working directory for the log file
setwd("/Users/John/Dropbox/JOP_Replication_Materials/Logs/")
# --- Define helper function FIRST ---
run_script <- function(script_path) {
original_wd <- getwd()
script_dir <- dirname(script_path)
script_file <- basename(script_path)
setwd(script_dir)
cat("\n--- Running:", script_file, "from", script_dir, "at", Sys.time(), "---\n")
tryCatch({
source(script_file, echo = TRUE)
}, error = function(e) {
cat("ERROR in", script_file, ":", conditionMessage(e), "\n")
})
setwd(original_wd)
}
# Start logging AFTER functions are defined
sink("replication_log.txt", split = TRUE)
cat("Replication Log started at", Sys.time(), "\n\n")
# Define paths
main_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/code/"
appendix_code_dir <- "/Users/John/Dropbox/JOP_Replication_Materials/appendix/code/"
# List of main scripts
main_scripts <- c(
"02_create_hhi.R",
"03_create_soe_share.R",
"04_create_final_dataset.R",
"05_create_total_isic.R",
"06_figure_1.R",
"07_figure_2.R",
"08_figure_3.R",
"09_table_1.R",
"10_figure_4.R",
"11_figure_5.R"
)
# List of appendix scripts
appendix_scripts <- c(
"B1_create_table_1.R",
"B2_create_alt_strategic.R",
"B3_create_figure_3.R",
"B4_create_table_2.R",
"B5_create_table_3.R",
"C1_create_rnd_only.R",
"C2_create_figure_4.R",
"C3_create_gp0911_only.R",
"C4_create_figure_5.R",
"C5_create_figure_6.R",
"C6_create_figure_7.R",
"C7_create_figure_8.R",
"C8_create_or_only.R",
"C9_create_figure_9.R",
"C10_create_lcr_only.R",
"C11_create_figure_10.R",
"C12_create_gp_only.R",
"C13_create_figure_11.R",
"C14_create_figures_12_13.R",
"C15_create_figure_14.R",
"C16_create_figures_15_16.R",
"C17_create_figure_17.R",
"D1_create_table_4.R",
"E1_create_marketsize.R",
"E2_create_table_5.R",
"E3_create_table_6.R"
)
# Run all scripts
for (s in main_scripts) run_script(file.path(main_code_dir, s))
